package com.sxhuayuan.parking.controller.parkinglot.user;

import com.sxhuayuan.parking.compenent.Pageable;
import com.sxhuayuan.parking.compenent.web.RespMessage;
import com.sxhuayuan.parking.controller.BaseController;
import com.sxhuayuan.parking.entity.ParkingLotUser;
import com.sxhuayuan.parking.service.ParkingLotService;
import com.sxhuayuan.parking.service.ParkingLotUserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController("parkingLotUserParkingLotController")
@RequestMapping("/parkinglotuser/parkinglot")
public class ParkingLotController extends BaseController {

	@Resource(name = "parkingLotServiceImpl")
	ParkingLotService parkingLotService;

	@Resource(name = "parkingLotUserServiceImpl")
	ParkingLotUserService parkingLotUserService;


	/** 停车场分页条件查询 */
	@PostMapping("/list")
	public RespMessage list(@RequestBody Pageable pageable) {
		ParkingLotUser parkingLotUser = parkingLotUserService.getCurrent();
		if (parkingLotUser == null) {
			return RespMessage.error(RespMessage.Status.INVALID_TOKEN, "登录失效");
		}
		return successResp(parkingLotService.findPageByParkingLotUser(pageable, parkingLotUser));
	}

}
